Refactored the motor_controller