code samples from book