refactored Promise.resolver and made some minor optimizations