finished coding up edit function