     }
     
     public func registerProgress(_ block: @escaping (Float) -> Void) -> Promise<Void> {
-        let p = Promise<Void> { [weak self] resolve, reject, progress in
-            if let state = self?.state {
-                switch state {
-                case .fulfilled:
-                    resolve()
-                case let .rejected(error):
-                    reject(error)
-                case .pending:()
-                self?.failBlocks.append(reject)
-                self?.successBlocks.append({ _ in
-                    resolve()
-                })
-                }
-            }
-            self?.progressBlocks.append({ p in
-                block(p)
-                progress(p)
-            })
-        }
+        let p = Promise<Void>()
+        switch state {
+        case .fulfilled:
+            p.resolvePromise()
+        case let .rejected(error):
+            p.rejectPromise(error)
+        case .pending:() //
+        failBlocks.append(p.rejectPromise)
+        successBlocks.append({ _ in
+            p.resolvePromise()
+        })
+        }
+        progressBlocks.append({ v in
+            block(v)
+            p.progressPromise(v)
+        })
         p.start()
         passAlongFirstPromiseStartFunctionAndStateTo(p)
         return p

    
    @discardableResult public func registerOnError(_ block:
        @escaping (Error) -> Void) -> Promise<Void> {
        let p = Promise<Void> { [weak self] resolve, reject, progress in
            if let state = self?.state {
                switch state {
                case .fulfilled:
                    reject(NSError(domain: "", code: 123, userInfo: nil))
                // No error so do nothing.
                case let .rejected(error):
                    // Already failed so call error block
                    block(error)
                    resolve()
                case .pending:
                    // if promise fails, resolve error promise
                    self?.failBlocks.append({ e in
                        block(e)
                        resolve()
                    })
                    self?.successBlocks.append({ t in
                        resolve()
                    })
                }
            }
            self?.progressBlocks.append(progress)
        }
        p.start()
        passAlongFirstPromiseStartFunctionAndStateTo(p)
        return p

    
    @discardableResult  public func registerThen<X>(_ block: @escaping (T) -> Promise<X>)
        -> Promise<X> {
        let p = Promise<X>()
        switch state {
        case let .fulfilled(value):
            registerNextPromise(block, result: value,
                                      resolve: p.resolvePromise, reject: p.rejectPromise)
        case let .rejected(error):
            p.rejectPromise(error)
        case .pending:
            successBlocks.append({ t in
                self.registerNextPromise(block, result: t, resolve: p.resolvePromise,
                                         reject: p.rejectPromise)
            })
            failBlocks.append(p.rejectPromise)
        }
        p.start()
        passAlongFirstPromiseStartFunctionAndStateTo(p)
        return p
    }
    
    //MARK: - then(Promise<X>)
