get_cats function

Extract categories