just a minor tweak to the foreach loop