Refactoring getCategories