restore more complete code of the book