Refine the code to be more readiable