Exercise 1-18. Not sure if this is how it was intended to be written.