major refactoring for HTTP requests