modify the error in the book's original code