ToggleButton code tidied-up