added variables and enhanced codegen