Corrected a toggle function