implement edit function