refine the codes