fix for Promise.when