pwm rewritten