Wrong var being assigned for switch