added try catch
added try catch and logs