reorganize and add comments