Improved toggles code