finish exercise 4.7 in section 4.1.2