Edit function now works perfectly