fix toggle functionality