improved code generator