Exercise 8.4 cleaned up
Exercise 8.5