got the function to work correctly: the button alters between on and off