rework state machine generation