rewrote code generator for and