add verification of the existence before foreach()