Refactor http client