implementing for_do()