Added more code from the book