Fixing deprecation warning in Chapter 5 code