Refactoring for controller