                             completion(url)
                         }
                     }
+                    task = nil
                 }
             }
         }) 

                        onError(PreviewError.cannotBeOpened(url.absoluteString))
                    }
                }
            } else {
                if let finalResult = response?.url {
                    if (finalResult.absoluteString == url.absoluteString) {

                                completion(url)
                            }
                        }
                        task = nil
                    } else {
                        task!.cancel()
                        task = nil
