Fixed FOREACH loop