Converted the code to use the httpclient gem