rewrote custom_c_generator to use classes