refactor Promises.js