completed: switch from 'when.js' to 'q'