remove duplication of ANSI code generation