modified edit function