refine code