function [start_index,end_index]=End_point_Adjustment(data,I_Fit,Final_level_pts)

data_length=length(data);
[M,I]=min(data);

start_adjustment=0;
while data(I+start_adjustment)<0.999*I_Fit(1) && I+start_adjustment>1
    start_adjustment=start_adjustment-1;
end
start_index=I+start_adjustment;
if start_index<Final_level_pts(1)
   start_index=Final_level_pts(1);
end

end_adjustment=0;
while data(I+end_adjustment)<0.999*I_Fit(end) && I+end_adjustment<data_length
    end_adjustment=end_adjustment+1;
end
end_index=I+end_adjustment;
if end_index>Final_level_pts(end)
   end_index=Final_level_pts(end);
end
end