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

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

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