Changed switch command to exit when sub is complete
Scope fix