fixes syntax error - stray ;, and moved foreach statement inside curly braces