REFACTORED toggle code so checkbox and link toggles use the same code