initial commit from book code