fixing the IndexOutOfBounds