 //
 
 import Foundation
+
+private extension String {
+  
+  func charAt(_ i: Int) -> Character {
+    let index = self.index(self.startIndex, offsetBy: i)
+    return self[index]
+  }
+  
+  func charStrAt(_ i: Int) -> String {
+    return String(charAt(i))
+  }
+}
 
 public extension String {
   

      // Find next first case-insensitive match of word's i-th character.
      // The search in "string" begins at "startAt".
      
      if let range = lString.range(of:
        String(lWord[lWord.index(lWord.startIndex, offsetBy: i)] as Character),
                                   options: NSString.CompareOptions.caseInsensitive,
                                   range: Range<String.Index>(startAt..<lString.endIndex),
                                   locale: nil
        ) {
        // start index of word's i-th character in string.
        idxOf = range.lowerBound
        if startAt == idxOf {
          // Consecutive letter & start-of-string Bonus
          charScore = 0.7

    // Reduce penalty for longer strings.
    finalScore = 0.5 * (runningScore / Double(strLength) + runningScore / Double(wordLength)) / fuzzies
    
    if (finalScore < 0.85) &&
      (lWord.charStrAt(0).compare(lString.charStrAt(0), options: .diacriticInsensitive) == .orderedSame) {
      finalScore += 0.15
    }
    
