|laziness, impatience, and hubris
If you can, get out of the habit of relying on global variables in functions like that. It is a sure fire way to get confused about what is happening in your code.
In the debugger enter a session on your script and immediately do this:
When you get into the switch properties code step down until you hit the offending 'get' line and then do this:
What do you see?
Celebrate Intellectual Diversity