I think i'd do this once outside the loop with the length of numFlags