modified state machine