fix for StringIndexOutOfBoundsException