An implantable cardiac medical device comprising: sensing circuitry configured to obtain a cardiac signal using a plurality of electrodes; a memory that stores the cardiac electrical signal and a plurality of beats identified within the cardiac signal; a processor, wherein the processor is configured to obtain the plurality of identified beats, separate the plurality of identified beats into subgroups of beats, determine whether a number of beats in one of the subgroups exceeds a threshold, generate a beat template using the beats within the one of the subgroups when the number of beats in the one of the subgroups exceeds the threshold, and store the beat template in the memory; wherein the processor is configured to obtain a first beat of the plurality of beats, place the first beat in a first subgroup of the subgroups, and set the first beat as a first subgroup template beat; obtain a second beat of the plurality of beats that is subsequent to the first beat, compare the second beat to the first subgroup template beat, place the second beat in the first subgroup when the second beat matches the first subgroup template beat, place the second beat within a second subgroup of the subgroups when the second beat does not match the first subgroup template, and set the second beat as a second subgroup template beat.; and for each subsequent beat of the plurality of identified beats, the processor is configured to obtain the subsequent beat of the plurality of beats, compare the subsequent beat to the first subgroup template beat, place the subsequent beat in the first subgroup when the subsequent beat matches the first subgroup template beat, when the subsequent beat does not match the first subgroup template beat, determine whether the second subgroup includes any beats, if the second subgroup includes at least one beat, compare the subsequent beat to the second subgroup template beat and place the subsequent beat in the second subgroup when the subsequent beat matches the second subgroup template beat, when the subsequent beat does not match the second subgroup template beat, determine, in turn, whether any further subgroups include any beats and whether the subsequent beat matches the further subgroup template beats and, if so, place the subsequent beat in the further subgroup, and if the second or any further subgroup does not include any beats, place the subsequent beat in the second subgroup or next one of the further subgroups and set the subsequent beat as the subgroup template beat of that subgroup. sensing circuitry configured to obtain a cardiac signal using a plurality of electrodes; a memory that stores the cardiac electrical signal and a plurality of beats identified within the cardiac signal; a processor, wherein the processor is configured to obtain the plurality of identified beats, separate the plurality of identified beats into subgroups of beats, determine whether a number of beats in one of the subgroups exceeds a threshold, generate a beat template using the beats within the one of the subgroups when the number of beats in the one of the subgroups exceeds the threshold, and store the beat template in the memory; wherein the processor is configured to obtain a first beat of the plurality of beats, place the first beat in a first subgroup of the subgroups, and set the first beat as a first subgroup template beat; obtain a second beat of the plurality of beats that is subsequent to the first beat, compare the second beat to the first subgroup template beat, place the second beat in the first subgroup when the second beat matches the first subgroup template beat, place the second beat within a second subgroup of the subgroups when the second beat does not match the first subgroup template, and set the second beat as a second subgroup template beat.; and for each subsequent beat of the plurality of identified beats, the processor is configured to obtain the subsequent beat of the plurality of beats, compare the subsequent beat to the first subgroup template beat, place the subsequent beat in the first subgroup when the subsequent beat matches the first subgroup template beat, when the subsequent beat does not match the first subgroup template beat, determine whether the second subgroup includes any beats, if the second subgroup includes at least one beat, compare the subsequent beat to the second subgroup template beat and place the subsequent beat in the second subgroup when the subsequent beat matches the second subgroup template beat, when the subsequent beat does not match the second subgroup template beat, determine, in turn, whether any further subgroups include any beats and whether the subsequent beat matches the further subgroup template beats and, if so, place the subsequent beat in the further subgroup, and if the second or any further subgroup does not include any beats, place the subsequent beat in the second subgroup or next one of the further subgroups and set the subsequent beat as the subgroup template beat of that subgroup.