tried to fix the IndexOutOfBoundsErrors.