rewrite efsm to efsm_template