     
     public func textFieldShouldClear(_ textField: UITextField) -> Bool {
         containedAttributedText = NSMutableAttributedString()
+        chosenTags.removeAll()
         return true
     }
 }

    private var userTextField: UITextField!
    
    private var collection = [String]()
    private var tagCharacter = String()
    private var containedAttributedText = NSMutableAttributedString()
    

        else { return }
        
        let trimmedLastWord = lastWord.trimmingCharacters(in: .whitespaces)
        for index in 0...collection.count-1 {
            if tagCharacter + collection[index] == trimmedLastWord || chosenTags.contains(trimmedLastWord) {
                updateContainedAttributedText()
                containedAttributedText.replaceCharacters(in: NSMakeRange(containedAttributedText.string.characters.count - trimmedLastWord.characters.count,
                                                                          trimmedLastWord.characters.count), with: "")
                userTextField.attributedText = containedAttributedText
                
                guard let index = chosenTags.index(of: trimmedLastWord) else { return }
                chosenTags.remove(at: index)
                break;
            }
        }
        translateCompletionTextHolderDown(with: nil)
