replace for with each-do loops