modified edit method

- added try and catch blocks to handle exceptions