Code for a foreach loop