added try-catch around json parsing