Refactor controller.