fixed result behavior with empty foreach loops