Refactored to prevent frequent Iterator creation.