         
         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)
+                if let bulletIndex = textView.text.previousIndexOfSubstring(RichTextViewController.bulletedLineStarter, fromIndex: textView.selectedRange.location) {
+                    removeTextFromRange(NSRange(location: bulletIndex, length: RichTextViewController.bulletedLineStarter.length), fromTextView: textView)
                 }
             } else {
                 let newLineIndex = (textView.text.previousIndexOfSubstring("\n", fromIndex: textView.selectedRange.location) ?? -1) + 1
-                addText(bulletedLineStarter, toTextView: textView, atIndex: newLineIndex)
+                addText(RichTextViewController.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) {
+            if selectionContainsBulletedList(NSRange(location: textView.selectedRange.location, length: 0)), let bulletIndex = textView.text.previousIndexOfSubstring(RichTextViewController.bulletedLineStarter, fromIndex: textView.selectedRange.location) {
                 bulletsInSelection = true
-                removeTextFromRange(NSRange(location: bulletIndex, length: bulletedLineStarter.length), fromTextView: textView)
+                removeTextFromRange(NSRange(location: bulletIndex, length: RichTextViewController.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)
+                while index < textView.text.length {
+                    guard let nextBulletIndex = textView.text.nextIndexOfSubstring(RichTextViewController.bulletedLineStarter, fromIndex: index) else { break }
+
+                    removeTextFromRange(NSRange(location: nextBulletIndex, length: RichTextViewController.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)
+                addText(RichTextViewController.bulletedLineStarter, toTextView: textView, atIndex: newLineIndex)
                 
                 var index = textView.selectedRange.location
-                while true {
-                    guard let nextLineIndex = textView.text.nextIndexOfSubstring("\n", fromIndex: index)  else { break }
+                while index < textView.text.length {
+                    guard let nextLineIndex = textView.text.nextIndexOfSubstring("\n", fromIndex: index) else { break }
                     
-                    addText(bulletedLineStarter, toTextView: textView, atIndex: nextLineIndex + 1)
+                    addText(RichTextViewController.bulletedLineStarter, toTextView: textView, atIndex: nextLineIndex + 1)
                     index = nextLineIndex + 1
                 }
             }
         }
     }
+    
 }
 
 extension RichTextViewController: UITextViewDelegate {

    
    private func moveSelectionIfInRangeOfBulletedList() {
        guard textView.text.length > 1 && textView.selectedRange.location < textView.text.length else { return }
        
        
        var range = NSRange(location: textView.selectedRange.location, length: textView.selectedRange.length)
        if range.length == 0 && range.location > 0 {


        return !changed
    }
    
}
