added onoff method for switch functionality