refactored iteration