using when.js for async calls