converted from Q to a promise polyfill