switch state is called