Fixed a bug with empty foreach