Refactor promise