removed unnecessary $.when(defer).then calls for defer.then()