added StateMachine class