Remaining Chapter 2 code