work on state machine