write the loop as a block