scope of switch variable ended up being limited to cases