Just adding some of the book code for reference