Promises refactoring