Refactoring the controller.