add switch state function.