refine  code