cgen func added