added snippets from chapter 4