Chapter 7 implementation from Chapter 7 book: Collective Intelligence