function [n5ntvalue, counter, time_elapsed] = mydissfuniii_newton(carbon, hydrogen, oxygen, temperature, fuelequiv, molar_air_stoich, pressure)
    % Newton's Method for n5nt, ensuring the correct number of columns

    tic; % Start timing
    counter = 0; % Iteration counter
    tol = 1e-12; % Lower tolerance for better accuracy
    imax = 500; % Higher max iterations to ensure proper convergence
    
    % Set initial guess based on the original method
    n5ntvalue = 0.1;  
    abs_diff = inf;

    % 🔹 **Ensure Gibbs Free Energy Dataset is Correct**
    gibbseng = [
        0 -393.151 -238.921 -113.805;
        100 -393.683 -236.584 -120.239;
        200 -394.085 -232.766 -128.526;
        298.15 -394.389 -228.582 -137.163;
        300 -394.394 -228.5 -137.328;
        400 -394.675 -223.901 -146.338;
        500 -394.939 -219.051 -155.414;
        600 -395.182 -214.007 -164.486;
        700 -395.398 -208.812 -173.518;
        800 -395.586 -203.496 -182.497;
        900 -395.748 -198.083 -191.416;
        1000 -395.886 -192.59 -200.275;
        1100 -396.001 -187.033 -209.075;
        1200 -396.098 -181.425 -217.819;
        1300 -396.177 -175.774 -226.509;
        1400 -396.24 -170.089 -235.149;
        1500 -396.288 -164.376 -243.74;
        1600 -396.323 -158.639 -252.284;
        1700 -396.344 -152.883 -260.784;
        1800 -396.353 -147.111 -269.242;
        1900 -396.349 -141.325 -277.658;
        2000 -396.333 -135.528 -286.034;
        2100 -396.304 -129.721 -294.372;
        2200 -396.262 -123.905 -302.672;
        2300 -396.209 -118.082 -310.936;
        2400 -396.142 -112.252 -319.165;
        2500 -396.062 -106.416 -327.358;
        2600 -395.969 -100.575 -335.517;
        2700 -395.862 -94.729 -343.643;
        2800 -395.742 -88.878 -351.736;
        2900 -395.609 -83.023 -359.797;
        3000 -395.461 -77.163 -367.826
    ];

    % Compute Gibbs Free Energies using interpolation
    gco2 = interp1(gibbseng(:,1), gibbseng(:,2), temperature) * 1e3;
    gh2o = interp1(gibbseng(:,1), gibbseng(:,3), temperature) * 1e3;
    gco = interp1(gibbseng(:,1), gibbseng(:,4), temperature) * 1e3;

    % Compute equilibrium constants
    kco2 = exp(-(gco2 - gco) * 1e3 / (8314.46 * temperature));
    kh2o = exp(-gh2o * 1e3 / (8314.46 * temperature));

    % 🔹 **Ensure Variable Consistency**
    airs = molar_air_stoich; % Ensure the same variable is used

    % 🔹 **Newton's Method Iteration**
    while abs_diff > tol && counter < imax
        counter = counter + 1;
        
        % Compute function value f(n5nt)
        a = sqrt(n5ntvalue * pressure);
        n3 = (carbon * fuelequiv) / (kco2 * a + 1);
        n4 = ((hydrogen / 2) * fuelequiv) / (kh2o * a + 1);
        n1 = carbon * fuelequiv - n3;
        n2 = (hydrogen / 2) * fuelequiv - n4;
        n5 = (airs * 2 + oxygen * fuelequiv - 2 * n1 - n2 - n3) / 2;
        n6 = airs * 3.76;
        ntsum = n1 + n2 + n3 + n4 + n5 + n6;
        f_val = n5ntvalue - n5 / ntsum;

        % Compute derivative df/d(n5nt) numerically
        h_step = 1e-8;
        a_h = sqrt((n5ntvalue + h_step) * pressure);
        n3_h = (carbon * fuelequiv) / (kco2 * a_h + 1);
        n4_h = ((hydrogen / 2) * fuelequiv) / (kh2o * a_h + 1);
        n1_h = carbon * fuelequiv - n3_h;
        n2_h = (hydrogen / 2) * fuelequiv - n4_h;
        n5_h = (airs * 2 + oxygen * fuelequiv - 2 * n1_h - n2_h - n3_h) / 2;
        ntsum_h = n1_h + n2_h + n3_h + n4_h + n5_h + n6;
        f_val_h = (n5ntvalue + h_step) - n5_h / ntsum_h;
        df_val = (f_val_h - f_val) / h_step;

        % 🔹 **Proper Newton’s Update**
        newton_step = f_val / df_val;
        n5nt_next = n5ntvalue - newton_step;

        % Ensure step size is reasonable
        if abs(n5nt_next - n5ntvalue) > 1e-3
            n5nt_next = n5ntvalue - sign(f_val) * 1e-3;
        end

        % Check tolerance
        abs_diff = abs(n5nt_next - n5ntvalue);

        % Update value
        n5ntvalue = n5nt_next;
    end

    % Stop timing
    time_elapsed = toc;
end
