Exercise 4 with comments.