         while !scanner.isAtEnd && scanner.scanLocation < self.parseRange.max {
             guard !self.isCancelled else { return [] }
             
-            var scanningString: NSString?
+            var scannedString: NSString?
             scanner.scanUpToCharacters(from: charSet, into: nil)
             guard
-                scanner.scanCharacters(from: charSet, into: &scanningString),
-                let scannedString = scanningString as? String else { break }
-            
-            let length = scannedString.utf16.count
-            var words: [String] = wordsDict[length] ?? []
-            var isFound = words.contains(scannedString)
-            
-            if !isFound {
-                words = ignoreCaseWords[length] ?? []
-                isFound = words.contains(scannedString.lowercased())
-            }
-            
-            if isFound {
-                let location = scanner.scanLocation
-                let range = NSRange(location: location - length, length: length)
-                ranges.append(range)
-            }
+                scanner.scanCharacters(from: charSet, into: &scannedString),
+                let word = scannedString as? String else { break }
+            
+            let length = word.utf16.count
+            
+            guard words.contains(word) || ignoreCaseWords.contains(word.lowercased()) else { continue }
+            
+            let range = NSRange(location: scanner.scanLocation - length, length: length)
+            ranges.append(range)
         }
         
         return ranges

    // MARK: Private Methods
    
    /// extract ranges of passed-in words with Scanner by considering non-word characters around words
    private func ranges(simpleWords wordsDict: [Int: [String]], ignoreCaseWords: [Int: [String]], charSet: CharacterSet) -> [NSRange] {
        
        var ranges = [NSRange]()
        

                DispatchQueue.main.async {
                    childProgress.completedUnitCount += 1
                }
            }
            
            guard !self.isCancelled else { return [:] }
            
            // extract simple words
            if let charSet = self.simpleWordsCharacterSets?[syntaxType], !charSet.isEmpty {
                ranges += self.ranges(simpleWords: simpleWords,
                                      ignoreCaseWords: simpleICWords,
                                      charSet: charSet)
            }
            
            // store range array
