refactored click events for toggle buttons