Refactored toggle.js slightly