implementation of futures and promises and jQuery.Deferred.