Refactor promises