rewrite the book logic