             }
         }
     }
-
-    
-    var partialFormatter: PartialFormatter?
-    
-    let nonNumericSet: CharacterSet = {
-        var mutableSet = (CharacterSet.decimalDigits.inverted as NSCharacterSet).mutableCopy() as! NSMutableCharacterSet
-        mutableSet.removeCharacters(in: PhoneNumberConstants.plusChars)
-        return mutableSet as CharacterSet
+    
+    
+    let partialFormatter: PartialFormatter
+    
+    let nonNumericSet: NSCharacterSet = {
+        var mutableSet = NSMutableCharacterSet.decimalDigit().inverted
+        mutableSet.remove(charactersIn: PhoneNumberConstants.plusChars)
+        return mutableSet as NSCharacterSet
     }()
     
     weak private var _delegate: UITextFieldDelegate?

    }
    
    // Finds position of previous cursor in new formatted text
    internal func selectionRangeForNumberReplacement(_ textField: UITextField, formattedText: String) -> NSRange? {
        let textAsNSString = formattedText as NSString
        var countFromEnd = 0
        guard let cursorPosition = extractCursorPosition() else {

            let selectionRange = textField.textRange(from: selectionRangePosition, to: selectionRangePosition)
            textField.selectedTextRange = selectionRange
        }
        
        return false
    }
    
