add book's answer for exercise 3