refactoring the HTTP connections