add functions used in chapter 9