             range.length = 1
         }
         
-        attributedString.enumerateAttributesInRange(range, options: []) { dictionary, range, stop in
+        attributedString.enumerateAttributesInRange(range, options: []) { dictionary, _, _ in
             guard let font = dictionary[NSFontAttributeName] as? UIFont, boldFont = self.boldFont, boldItalicFont = self.boldItalicFont else { return }
             
             bolded = font == boldFont || font == boldItalicFont

        
        if textView.selectedRange.length == 0 {
            if selectionContainsBulletedList(textView.selectedRange) {
                if let bulletIndex = textView.text.previousIndexOfSubstring(bulletedLineStarter, fromIndex: textView.selectedRange.location) {
                    removeTextFromRange(NSRange(location: bulletIndex, length: bulletedLineStarter.length), fromTextView: textView)
                }
            } else {
                let newLineIndex = (textView.text.previousIndexOfSubstring("\n", fromIndex: textView.selectedRange.location) ?? -1) + 1
                addText(bulletedLineStarter, toTextView: textView, atIndex: newLineIndex)
            }
        } else {
            var bulletsInSelection = false
            
            if selectionContainsBulletedList(NSRange(location: textView.selectedRange.location, length: 0)), let bulletIndex = textView.text.previousIndexOfSubstring(bulletedLineStarter, fromIndex: textView.selectedRange.location) {
                bulletsInSelection = true
                removeTextFromRange(NSRange(location: bulletIndex, length: bulletedLineStarter.length), fromTextView: textView)
            }
            
            if selectionContainsBulletedList(textView.selectedRange) {
                bulletsInSelection = true
                var index = textView.selectedRange.location
                while true {
                    guard let nextBulletIndex = textView.text.nextIndexOfSubstring(bulletedLineStarter, fromIndex: index)  else { break }

                    removeTextFromRange(NSRange(location: nextBulletIndex, length: bulletedLineStarter.length), fromTextView: textView)
                    index = nextBulletIndex
                }
            }
            
            if !bulletsInSelection {
                let newLineIndex = (textView.text.previousIndexOfSubstring("\n", fromIndex: textView.selectedRange.location) ?? -1) + 1
                addText(bulletedLineStarter, toTextView: textView, atIndex: newLineIndex)
                
                var index = textView.selectedRange.location
                while true {
                    guard let nextLineIndex = textView.text.nextIndexOfSubstring("\n", fromIndex: index)  else { break }
                    
                    addText(bulletedLineStarter, toTextView: textView, atIndex: nextLineIndex + 1)
                    index = nextLineIndex + 1
                }
            }
        }
    }
}

extension RichTextViewController: UITextViewDelegate {

        guard textView.selectedRange.location >= 2 else { return false }
        
        let previousNumber = previousNumberOfNumberedList(textView.selectedRange) ?? 0
        let previousNumberString = "\(previousNumber)\(RichTextViewController.numberedListTrailer)"
        let previousNumberRange = NSRange(location: range.location - previousNumberString.length + 1, length: previousNumberString.length)
        let previousBulletRange = NSRange(location: range.location - RichTextViewController.bulletedLineStarter.length + 1, length: RichTextViewController.bulletedLineStarter.length)
        let adjustedRange = NSRange(location: range.location + 1, length: 0)
        
        if selectionContainsNumberedList(adjustedRange) {
