codeGen refactory