improved export to state machine