Converted use of chains.js to jQuery deferred