copy more pwm code