Using deferred instead of Promise