added try-catch to json parsing