New function to retrieve categories and counts