implement foreach statement