Added error handling for bad result.