Fixed the IndexOutOfBounds error