Exercise 3.48: Write an implementation