Added flowchart and code