refactoring the http stuff