refactored, added support for http promise