Adding code from the book.
4.35