 import Foundation
 
 extension String {
-    /// Allows us to use String[index] notation
-    public subscript(index: Int) -> String? {
-        let array = Array(characters)
-        return array.indices ~= index ? String(array[index]) : nil
-    }
-
-    /// var string = "abcde"[0...2] // string equals "abc"
-    /// var string2 = "fghij"[2..<4] // string2 equals "hi"
-    public subscript (r: Range<Int>) -> String {
+    /// var string = "abcde"[r: 0...2] // string equals "abc"
+    /// var string2 = "fghij"[r: 2..<4] // string2 equals "hi"
+    public subscript(r: Range<Int>) -> String {
         let start = index(startIndex, offsetBy: r.lowerBound)
-        let end   = index(startIndex, offsetBy: r.upperBound)
+        let end = index(startIndex, offsetBy: r.upperBound)
         return substring(with: Range(start..<end))
     }
 

    /// - returns: String without the specified `prefix` or nil if `prefix` doesn't exists.
    public func stripPrefix(_ prefix: String) -> String? {
        guard let prefixRange = range(of: prefix) else { return nil }
        let attributeRange  = Range(prefixRange.upperBound..<endIndex)
        let attributeString = substring(with: attributeRange)
        return attributeString
    }

    public func numberOfLines(_ font: UIFont, constrainedToSize: CGSize) -> (size: CGSize, numberOfLines: Int) {
        let textStorage = NSTextStorage(string: self, attributes: [NSFontAttributeName: font])

        let textContainer = NSTextContainer(size: constrainedToSize)
        textContainer.lineBreakMode = .byWordWrapping
        textContainer.maximumNumberOfLines = 0
        textContainer.lineFragmentPadding = 0

        let layoutManager = NSLayoutManager()
        layoutManager.textStorage = textStorage
        layoutManager.addTextContainer(textContainer)

        var numberOfLines = 0
        var index = 0
        var lineRange = NSRange(location: 0, length: 0)
        var size = CGSize.zero

        while index < layoutManager.numberOfGlyphs {
            numberOfLines += 1
