A ventilator system for controlling mechanical ventilation, the ventilator system comprises: one or more processors; a flow and pressure control valve (3), an exhalation valve (4), a flow transducer (5), and a pressure transducer (6) of the ventilator system; and a memory including instructions that, when executed by the one or more processors, cause the one or more processors to: supply, using the ventilator, a breathing gas from a source of gas (11) to an airway connector (10) configured to deliver the breathing gas to an airway of a patient; servo control the flow and pressure control valve (3) and the exhalation valve (4) of the ventilator system to intermittently switch an airway pressure, supplied to the airway connector, between a substantially constant first baseline pressure level and a substantially constant second baseline pressure level; measuring inspiratory flow by the flow transducer (5) positioned downstream from the flow and pressure control valve (3);detect a spontaneous inspiration effort to cause a drop in a pressure or volume at the airway connector (10) inside a preset trigger time window that immediately precedes a switching event at the end of a preset first period of time in which the breathing gas is to be switched between the first baseline pressure and the second baseline pressure; maintain a baseline pressure at a pressure level in which the inspiration effort was detected by increasing the first period of time by a delay time so that an inspiration-exhalation cycle is completed during the delay time prior to the switching event; and servo control the flow and pressure control valve (3) and the exhalation valve (4) to switch the baseline pressure level after the delay time.