Added PWM failsafe logic