             return task as? WTURLSessionTask
         }
         set{
-            let task = objc_getAssociatedObject(self, &WTUIButtonImageDownloadTaskKey)
-            if task != nil {
-                if task is URLSessionDataTask {
+            if let task = objc_getAssociatedObject(self, &WTUIButtonImageDownloadTaskKey){
+                if task is WTURLSessionTask {
                     let myTask:WTURLSessionTask = task as! WTURLSessionTask
                     myTask.cancel()
                 }

        set{
            let task = objc_getAssociatedObject(self, &WTUIImageViewHighLightedImageDataTaskKey)
            if task != nil {
                if task is URLSessionDataTask {
                    let myTask:WTURLSessionTask = task as! WTURLSessionTask
                    myTask.cancel()
                }

        set{
            let task = objc_getAssociatedObject(self, &WTUIButtonBackgroundImageDownloadTaskKey)
            if task != nil {
                if task is WTURLSessionTask {
                    let myTask:WTURLSessionTask = task as! WTURLSessionTask
                    myTask.cancel()
                }
