Added template duplication function