implemented first two blocks of Authenticate flowchart