Corrected code for handling switch release events.