A method and system for delivering a gas containing carbon dioxide to a patient are described. The method comprises measuring a physiological parameter of breathing stability in the patient determining an optimal gas delivery parameter based on the physiological parameter of breathing stability and delivering the gas to the patient in accordance with the optimal gas delivery parameter.