finish edit function