added foreach  to check effective looping