fixed error handling for json parsing