additional condition to avoid foreach error