make the state machine