More code based on examples in book