function Tops = findWrongTopsAutoGUI(Tops,hasChanged)
%     if hasChanged == 0
%         return;
%     end
    yTops = Tops(:,1);
    wrongTops = [];
    thresh = 60;
    
    for i = 2:length(yTops)-1
        diffLeft = yTops(i) - yTops(i-1);
        diffRight = yTops(i) - yTops(i+1);
        if (diffLeft<0 && diffRight<0 || diffLeft > 0 && diffRight > 0)
            if(abs(diffLeft) > thresh && abs(diffRight) > thresh)
                wrongTops(end+1,:) = Tops(i,:);
                %yTops(i) = [];
            end
        end
    end

    wrongLeft = abs(Tops(1,1) - Tops(2,1));
    %wrongLeft2 = abs(Tops(1,1) - Tops(3,1));
    if wrongLeft > thresh 
        wrongTops(end+1,:) = Tops(1,:);
    %elseif wrongLeft2 > thresh 
        %wrongTops(end+1,:) = Tops(1,:);
    end
    wrongRight = abs(Tops(end-1,1) - Tops(end,1));
   % wrongRight2 = abs(Tops(end-2,1) - Tops(end,1));
    if wrongRight > thresh 
        wrongTops(end+1,:) = Tops(end,:);
   % elseif wrongRight2>thresh
        % wrongTops(end+1,:) = Tops(end,:);
    end
   
   if ~isempty(wrongTops)
    Tops(ismember(Tops,wrongTops,'rows'),:)=[];
    hasChanged = 1;
   else
       hasChanged = 0;
   end
%  Tops = findWrongTopsAutoGUI(Tops, hasChanged);
  
end
