foreach error corrected