Changed deferred object to resolve correctly