added braces around foreach