Completed 'edit' function