corrected toggle code