add code of chapter 3