Updated loop to read the switchState tw to read the switch state twice