add function call on switch button