                          progressBlock: DownloadProgressBlock?,
                      completionHandler: CompletionHandler?) -> RetrieveImageTask
     {
-        
-        var indicator = UIActivityIndicatorView(activityIndicatorStyle:.Gray)
-        if ( showIndicatorWhenLoading == true)
-        {
-            indicator = UIActivityIndicatorView(activityIndicatorStyle:.Gray)
-            indicator.center = self.center
-            indicator.autoresizingMask = UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin|UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleTopMargin
-            if (!indicator.isAnimating ()) || (indicator.hidden)
-            {
-                indicator.hidden = false
-                if (indicator.superview == nil)
-                {
-                    self.addSubview(indicator)
-                }
-                indicator.startAnimating()
-            }
-        }
+        let showIndicatorWhenLoading = kf_showIndicatorWhenLoading
+        var indicator: UIActivityIndicatorView? = nil
+        if showIndicatorWhenLoading {
+            indicator = kf_indicator
+            indicator?.hidden = false
+            indicator?.startAnimating()
+        }
+        
         image = placeholderImage
         
         kf_setWebURL(URL)

}

// MARK: - Associated Object
private var lastURLkey: Void?
private var showIndicatorWhenLoading: Bool?
public extension UIImageView {
    /// Get the image URL binded to this image view.
    public var kf_webURL: NSURL? {
        get {
            return objc_getAssociatedObject(self, &lastURLkey) as? NSURL
        }
    }
    
    public var kf_showIndicatorWhenLoading: Bool?
    {
        get{
            return showIndicatorWhenLoading
        }
        set(newVal){
            showIndicatorWhenLoading = newVal
        }
    }
    
    private func kf_setWebURL(URL: NSURL) {
        objc_setAssociatedObject(self, &lastURLkey, URL, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
    }
}


                dispatch_async(dispatch_get_main_queue(), { () -> Void in
                    if let sSelf = self where imageURL == sSelf.kf_webURL && image != nil {
                        sSelf.image = image;
                        indicator?.hidden = true
                    }

                    completionHandler?(image: image, error: error, cacheType: cacheType, imageURL: imageURL)
                })
            })
        
