Updated the code for PWM