fix edit function to template