Added HTTP retrying and error handling