                 
                 var source = try String(contentsOfURL: sourceUrl, encoding: encodingArray[0]).extendedTrim
                 
-                dispatch_async(dispatch_get_main_queue()) {
-                    
+                if self.wasOnMainThread {
+                    
+                    dispatch_async(dispatch_get_main_queue()) {
+                        
+                        source = self.cleanSource(source)
+                        
+                        self.performPageCrawling(source)
+                        
+                        completion()
+                    }
+                }
+                else {
                     source = self.cleanSource(source)
                     
                     self.performPageCrawling(source)
                     
                     completion()
-                    
                 }
                 
             } catch _ as NSError {

                
                if(finalResult.absoluteString == url.absoluteString) {
                    
                    dispatch_async(dispatch_get_main_queue()) {
                        
                        completion(url)
                        
                    }
                    
                } else {

                
            } else {
                
                if self.wasOnMainThread {
                    
                    dispatch_async(dispatch_get_main_queue()) {
                        
                        completion(url)
                    }
                }
                else {
                    completion(url)
                }
            }
            
        }
