begin to rewrite code generation part