Fix generated book function