clean up foreach error