Added a bunch of functions from chapter 7