added error handling to json decoding