Adding in the code from the book.
4.30
4.31