assignment 2 code with comments