state machine redesign