added try catch block