changed promise lib to when.js