add toggle logic for buttons