Fixed bug in which toggle switch didn't toggle off correctly