refine and add comments