edit function now works well