transcribed some more of the chapter example code;