started working on the state machine