A system for controlling an amount of at least one gas X in a subject's lung to target at least one end tidal partial pressure of at least one gas X (PetXT) uses a control system for controlling the gas delivery device, wherein the control system implements a sequential gas delivery system and a feedback algorithm which compares a PetXT for a respective breath of variable size and preferably a respective current PetX value measured by a measurement system, to obtain an error signal, the feedback algorithm adapted for generating a control signal based on the error signal, the control signal determining the amount of gas X to be inspired by the subject in at least a first portion of a respective ensuing respective inspiratory cycle to target PetXT for the respective interval.