part of codegen, still need works(read comments)