refactored httpclient method.