refactor promises