refactor chapter 13