Required another nested foreach loop