add code of chapter 4