optimized ndfsm_to_dfsm