Add some chapter 4 codes