refactoring categories helper