Foreach block implementation