Implemented chapter 5 exercise improvements