example code from book