refine the code, add comments to result to self interpret