improved pwm example