Changed the sourcecode to the deferred method in jQuery