Use a data provider instead of a foreach loop.