Fixed an index out of bounds exception.