Corrected toggle fucntion