Add codes to Chapter 2