added new function to exercise from chapter 16