Altered scripts and added flowchart