function [A,B,C]=compare_asynch_waveform_clusters_to_phasic_waveform(iD,iE,iF,iG,iH,iI,A,B,C)

waveform_currently_jittering=iD(1,:);
iD(1,:)=[];

if isempty(iD)
    
    if ~isempty(iE)
        tmp = sum(iE,1);
    else
        tmp = zeros(1,size(iH,2));
    end
    
    for dejitter=iI
        tmp2 = tmp + waveform_currently_jittering(dejitter+iH);
        summed_event=sum(tmp2,1);
        fit_error=sum((summed_event-iF).^2)/iG;
        if fit_error<A,
            A=fit_error;
            if fit_error<B
                B=fit_error;
                C=summed_event;
            end
        end
    end
else
    tmp = [iE; zeros(1,size(iH,2))];
    
    for dejitter=iI
        tmp(end,:) = waveform_currently_jittering(dejitter+iH);
        [A,B,C]= compare_asynch_waveform_clusters_to_phasic_waveform(iD,tmp,iF,iG,iH,iI,A,B,C);
    end
end


end