Implement complete command and refactor code in controller.