Refactored controller.