chapter 24, exercise 1 modifications, so that it's reusable