forking treebook code to repurpose