         var removeRanges: [NSRange] = []
 
         let min = [text.count, format.phoneFormat.count].min() ?? 0
-        for i in 0 ..< min {
-            let index = phoneFormat.index(phoneFormat.startIndex, offsetBy: i)
+        for idx in 0 ..< min {
+            let index = phoneFormat.index(phoneFormat.startIndex, offsetBy: idx)
             let formatChar = phoneFormat[index]
             if formatChar != text[index] {
                 break
             }
 
             if isValuableChar(char: formatChar) {
-                let newRange = NSRange(location: i, length: 1)
+                let newRange = NSRange(location: idx, length: 1)
                 removeRanges.append(newRange)
             }
         }


        while start >= 0 && lasts > 0 {
            let indexChar = text.index(text.startIndex, offsetBy: index)
            let ch = text[indexChar]
            if isValuableChar(char: ch) {
                lasts -= 1
            }


    private func applyFormat(text: String, format: PhoneFormat, prefix: String?) -> String {
        var result: [Character] = []

        var idx = 0
        var charIndex = 0
        let phoneFormat = format.phoneFormat
        while idx < phoneFormat.count && charIndex < text.count {
            let index = phoneFormat.index(phoneFormat.startIndex, offsetBy: idx)
            let character = phoneFormat[index]
            if isRequireSubstitute(char: character) {
                let charIndexItem = text.index(text.startIndex, offsetBy: charIndex)
                let strp = text[charIndexItem]
                charIndex += 1
                result.append(strp)
            } else {
                result.append(character)
            }
            idx += 1
        }
        return (prefix ?? "") + String(result)
    }
