First version of exercise 4 in chapter 3.