Refactored code on the Category controller