move book rendering functionality into it's own function to dry up the code a bit