round 5, pseudo code with comments