             return false
         } else if text.utf16.count > 1 {
             // Pasting
-            _ = mentions |> mentionBeingEdited(at: range) |> clearMention()
+            _ = mentions |> mentionBeingEdited(at: range) >=> clearMention()
 
             textView.delegate = nil
             // The following snippet is because if you click on a predictive text without this snippet
             // the predictive text will be added twice.
             let originalText = mentionsTextView.attributedText
-            _ = mentionsTextView.attributedText |> replace(charactersIn: range, with: text)
+            _ = mentionsTextView.attributedText
+                |> replace(charactersIn: range, with: text)
             mentionsTextView.attributedText = originalText
-            mentionsTextView.attributedText |>
-                replace(charactersIn: range, with: text) |>
-                selectRange(on: mentionsTextView)
-
-            mentionsTextView.attributedText |> apply(defaultTextAttributes, range: range.adjustLength(for: text))
+            mentionsTextView.attributedText
+                |> replace(charactersIn: range, with: text)
+                |> selectRange(on: mentionsTextView)
+
+            mentionsTextView.attributedText
+                |> apply(defaultTextAttributes, range: range.adjustLength(for: text))
             mentionsTextView.scrollRangeToVisible(mentionsTextView.selectedRange)
-            mentions |> adjusted(forTextChangeAt: range, text: text)
+            mentions = mentions |> adjusted(forTextChangeAt: range, text: text)
             adjust(textView, range: textView.selectedRange)
             textView.delegate = self
 

    @discardableResult private func shouldAdjust(_: UITextView, range: NSRange, text: String) -> Bool {
        var shouldAdjust = true

        if mentions |> mentionBeingEdited(at: range) |> clearMention() {
            mentionsTextView.attributedText |>
                replace(charactersIn: range, with: text) |>
                selectRange(on: mentionsTextView)
            shouldAdjust = false
        }

        mentions |> adjusted(forTextChangeAt: range, text: text)

        return shouldAdjust
    }

    private func clearMention() -> (Mention?) -> Bool {
        return { mention in
            guard let mention = mention else { return false }
            self.mentions = self.mentions |> remove([mention])
            self.mentionsTextView.attributedText
                |> apply(self.defaultTextAttributes, range: mention.range)

            return true
        }
