corrected edit function