fix toggle function