updated
added try-catch block