Updated the edit function