fix issues with switch button not retaining state