                     range.length = newLength
                 }
             } else if range.location + range.length < textView.text.length - 1 && stringAtRange(NSRange(location: (range.location + range.length) - 1, length: 1)) == "\n",
-                let nextTrailerIndex = textView.text.nextIndexOfSubstring(numberedListTrailer, fromIndex: range.location + range.length) {
+                let nextTrailerIndex = textView.text.nextIndexOfSubstring(RichTextViewController.numberedListTrailer, fromIndex: range.location + range.length) {
                     let nextLineIndex = textView.text.nextIndexOfSubstring("\n", fromIndex: range.location + range.length) ?? textView.text.length - 1
                     if nextTrailerIndex < nextLineIndex {
                         if previousSelection.length < range.length {
-                            var newLength = textView.text.nextIndexOfSubstring(numberedListTrailer, fromIndex: range.location + range.length) ?? range.length - 1
+                            var newLength = textView.text.nextIndexOfSubstring(RichTextViewController.numberedListTrailer, fromIndex: range.location + range.length) ?? range.length - 1
                             newLength = newLength != range.length - 1 ? (newLength - range.location) + 2 : 0
                             range.length = newLength
                         } else {

                let previousNumber = previousNumberOfNumberedList(textView.selectedRange)
                var newNumber = previousNumber + 1
                
                let previousNumberedIndex = textView.text.previousIndexOfSubstring(numberedListTrailer, fromIndex: textView.selectedRange.location) ?? -2
                let previousNewLineIndex = textView.text.previousIndexOfSubstring("\n", fromIndex: textView.selectedRange.location) ?? -1
                
                if previousNumberedIndex < previousNewLineIndex {
                    addText("\(newNumber)\(numberedListTrailer)", toTextView: textView, atIndex: previousNewLineIndex + 1)
                    newNumber += 1
                }
                
                var index = textView.selectedRange.location
                
                while true {
                    guard let newLineIndex = textView.text.nextIndexOfSubstring("\n", fromIndex: index) where
                        newLineIndex < textView.selectedRange.endLocation else { break }
                    addText("\(newNumber)\(numberedListTrailer)", toTextView: textView, atIndex: newLineIndex + 1)
                    newNumber += 1
                    index = newLineIndex + 1
                }

                if let newLineIndex = textView.text.previousIndexOfSubstring("\n", fromIndex: textView.selectedRange.location) {
                    let previousNumber = previousNumberOfNumberedList(textView.selectedRange)

                    let range = NSRange(location: newLineIndex+1, length: "\(previousNumber)\(RichTextViewController.numberedListTrailer)".length)
                    removeTextFromRange(range, fromTextView: textView)
                } else {
                    removeTextFromRange(NSRange(location: 0, length: RichTextViewController.numberedListTrailer.length+1), fromTextView: textView)
                }
            } else {
                if let newLineIndex = textView.text.previousIndexOfSubstring("\n", fromIndex: textView.selectedRange.location) {
                    let newNumber = (previousNumberOfNumberedList(textView.selectedRange) ?? 0) + 1
                    let insertString = "\(newNumber)\(RichTextViewController.numberedListTrailer)"
                    addText(insertString, toTextView: textView, atIndex: newLineIndex + 1)
                } else {
                    let insertString = "1\(RichTextViewController.numberedListTrailer)"
                    addText(insertString, toTextView: textView, atIndex: 0)
                }
            }
