Created a promise
Fixed minor errors to promise/defer