function uclean=clean2(u)
%function uclean=clean2(u)
%            interpolates over bad points, taking care of 
%             isolated bad points and pairs of bad points
len=length(u);
bad=find(u==NaN);
l=length(bad);
if l>0

if bad(length(bad))==length(u)
      bad(length(bad))=[];
end
if length(bad)>0

u(length(u)+1)=NaN;
if bad(1)==1
     bad(1)=[];
end
u(bad)=u(bad-1)*2/3+u(bad+2)*1/3;
bad=bad(find(u(bad)==NaN));

if (length(bad))>0

if bad(1)==2
     bad(1)=[];
end
u(bad)=u(bad-2)*1/3+u(bad+1)*2/3;
uclean=u;
nfixed=l-length(find(u(bad)==NaN));

else 
uclean=u;
end

else 
uclean=u;
end

else uclean=u;
end
uclean=uclean(1:len);
