Changed the way the off input is detected