fixed a problem with switch state checking