refine some code