refine the code and the structure