Fix index of bounds exception.