refine iterator function