refactored iterator