refactoring to use enumerators and iteratees