Fix 'for each' bug