refactor Promise.js