Refactoring controller.