a few optimisations book.rb