Fixed a state change bug