Using the state machine