   }
   
   func rangeForTokenInsertion()-> NSRange {
-    //    textContainer.size = self.bounds.size
+    textContainer.size = self.bounds.size
+    println("size = \(textContainer.size.width) x \(textContainer.size.height)")
+    println("label size = \(self.frame.size.width) x \(self.frame.size.height)")
+    println("length \(textStorage.length)")
     let glyphIndex = layoutManager.glyphIndexForCharacterAtIndex(textStorage.length-1)
+    println("glyph index = \(glyphIndex)")
+
     var range = layoutManager.truncatedGlyphRangeInLineFragmentForGlyphAtIndex(glyphIndex)
-    if (range.location != NSNotFound && customTruncationEnabled) {
+    println("range = \(range.location) x \(range.length)")
+    if (range.length > 0 && customTruncationEnabled) {
       range.length += attributedTruncationToken!.length
       range.location -= attributedTruncationToken!.length
     }

    if (shouldAppendTruncationToken() && !truncationTokenAppended()) {
      if isNewLinePresent() {
        //Append token string at the end of last visible line
        textStorage.replaceCharactersInRange(rangeForTokenInsertionForStringWithNewLine(), withAttributedString: attributedTruncationToken!)
      }
    //Check for truncation range and append truncation token if required
    let tokenRange = rangeForTokenInsertion()

      if (tokenRange.location != NSNotFound) {
        self.textStorage.replaceCharactersInRange(tokenRange, withAttributedString:attributedTruncationToken!)
        self.redrawTextForRange(NSMakeRange(0, textStorage.length))
      }
//      //Apply attributes if truncation token appended
      let truncationRange = rangeOfTruncationToken()
      if (truncationRange.location != NSNotFound) {
        removeAttributeForTruncatedRange()

          if let attributes = descriptor.patternAttributes {
            textStorage.addAttributes(descriptor.patternAttributes!, range: truncationRange)
          }
        }
      }
    
    }

  }
