Fixed getCategories function