Refactoring for promise