refactored toggle control