refine loop