Array of objects and a foreach loop