better error handling in json decoding