source code of chapter 9: functions