Code samples for chapter 4