Chapter 9: fixed free bug