Implemented a StateMachine