Fixed typos
Fix for potentially invalid foreach