Refactoring to use jQuery Deferred