first working codegen implementation