completion of exercise 3 from chapter 2