Code rewriting to move to a Topic model