some refactoring for categries_controller, introduced some helper methods