Refine logic