update codes for chapter 1.