Refactor categories controller