Initial code from the TB_COR notebook