add comments and flowchart