completed code generator for template method