                 }
             default: break
             }
-            if startIndex != 0 { break }
+            if indexOffset != 0 { break }
         }
-        return str.startIndex.advancedBy(startIndex)
+        return str.startIndex.advancedBy(indexOffset)
     }
 }

            }
            switch letter {
            case " ", "\n", "\r", "\t":
                if i != index { startIndex = i + 1 }
                else {
                    startIndex = i - 1
                }
            case ":":
                if let _ = prevLetter {
                    if prevLetter == " " || prevLetter == ":" || prevLetter == nil {
                        if i != index { startIndex = i }
                    }
                    else {
                        break

    }

    func getIndexOfWordStart(index: Int, fromString str: String) -> String.Index {
        guard index > 0 else { return str.startIndex }
        var indexOffset = 0
        for i in (1 ... index).reverse() {
            let cursorIndex = str.startIndex.advancedBy(i)
            let letter = str[cursorIndex]
            var prevLetter: Character?
