refactoring the http call