refactored iteration flow