correct version of PWM code