added a transition when user clicks on the s switch to change the state