Fixed bug when using smartApps and code reduction

Fixed bug when calling switch other than switch1 form smartApps.
Code reduction