TRQ-2831 use the vector size directly as it might change during the body of the loop.