fixed string index out of bounds exception