function [vals, pos] = findPeaksBetter(x)
pos = [];
vals = [];
for k = 2 : length(x)-1
    idx1 = k - 5 : k - 1;
    idx2 = k +1 : k + 5;
    idx1(idx1 < 1) = [];
    idx1(idx1 > length(x)) = [];
    
    idx2(idx2 < 1) = [];
    idx2(idx2 > length(x)) = [];
    
    if mean(x(idx1)) < x(k) && mean(x(idx2)) < x(k)
        vals(end + 1) = x(k);
        pos(end + 1) = k;
    end
    
end
end

