function [Final_IT_array,Final_mean_I_array]=Final_Level_Construction_Light(data,Unmodified_DI_array,Final_mean_I_array,level_type,BSL,BSR,Final_level_pts,cutoff_pts,Final_dt_array)

levels=length(Final_level_pts)-1;

sub_event_size=Final_level_pts(1);
t_data=(1:Final_level_pts(1))';
Final_IT_array=[t_data repmat(BSL,sub_event_size,1)];
   
for i=1:levels

    if Final_level_pts(i+1)>length(data)
        level_in=Final_level_pts(i):length(data);
    else
        level_in=Final_level_pts(i):Final_level_pts(i+1);
    end
    
    t_data=(level_in)';
    sub_event_size=length(t_data);
    
    if levels>=2
        
        if level_type(i)==1
            if i~=levels
                if level_type(i+1)~=2
                    level_I=min([Unmodified_DI_array(i);Final_mean_I_array(i)]);
                    Final_mean_I_array(i)=level_I;
                else
                    level_I=Unmodified_DI_array(i);
                    Final_mean_I_array(i)=level_I;
                end
            else
                level_I=Unmodified_DI_array(i);
                Final_mean_I_array(i)=level_I;
            end
        end
        
        if level_type(i)==2
            level_I=max([Unmodified_DI_array(i);Final_mean_I_array(i)]);
            Final_mean_I_array(i)=level_I;
        end
        
        if level_type(i)==3
            level_I=Unmodified_DI_array(i);
            Final_mean_I_array(i)=level_I;
        end
    
    elseif levels==1 %one level events
    
        if length(level_in)>3 %there has to be atleast 3 points for findpeak to work
            level_data=data(level_in);
            smooth_data=smoothdata(level_data,'movmean',3);
            [~,pos] = findpeaks(-smooth_data);
            dt=sum(Final_dt_array);
            dt_criterion=max([1;dt/5]);
            if length(pos)>dt_criterion || dt>cutoff_pts
                level_I=Unmodified_DI_array(i);
                Final_mean_I_array(i)=level_I;
            else
                level_I=min([Unmodified_DI_array(i);Final_mean_I_array(i)]);
                Final_mean_I_array(i)=level_I;
            end
        else
            level_I=min([Unmodified_DI_array(i);Final_mean_I_array(i)]);
            Final_mean_I_array(i)=level_I;
        end
        
    end
    
    level_It=[t_data repmat(Final_mean_I_array(i),sub_event_size,1)];
    Final_IT_array=[Final_IT_array;level_It];
    
end
    level_in=Final_level_pts(end):length(data);
    t_data=level_in';
    sub_event_size=length(t_data);
    level_It=[t_data repmat(BSR,sub_event_size,1)];
    Final_IT_array=[Final_IT_array;level_It];
end