         } else {
             // if it's a new attachment tapped let unmark the previous one
             if let selectedAttachment = currentSelectedAttachment {
-                selectedAttachment.message = nil
+                selectedAttachment.clearAllOverlays()
                 richTextView.refreshLayoutFor(attachment: selectedAttachment)
             }
             // and mark the newly tapped attachment

        return true
    }

    func richTextViewWasPressed(_ recognizer: UIGestureRecognizer) {
        let locationInTextView = recognizer.location(in: richTextView)
        // check if we have an attachment in the position we tapped
        guard let attachment = richTextView.attachmentAtPoint(locationInTextView) else {
            // if we have an attachment marked lets unmark it
            if let selectedAttachment = currentSelectedAttachment {
                selectedAttachment.message = nil
                selectedAttachment.clearAllOverlays()
                richTextView.refreshLayoutFor(attachment: selectedAttachment)
                currentSelectedAttachment = nil


    fileprivate(set) lazy var tapGestureRecognizer: UIGestureRecognizer = {
        let recognizer = UITapGestureRecognizer(target: self, action: #selector(richTextViewWasPressed))
        recognizer.cancelsTouchesInView = true
        recognizer.delaysTouchesBegan = true
        recognizer.delaysTouchesEnded = true
        recognizer.delegate = self
        return recognizer
    }()
