fix StringIndexOutOfBoundsException