Separating the action from the iteration logic serves a few things. It makes each functional unit tighter and easier to understand. It makes it module, and more importantly it makes it extensible (e.g., we want to iterate over entries and do something else with them).