refactored to basic PWM motor code