chapter 3 template code update