updated the edit function