implemented foreach statement