rework state machine