The present invention relates to a solution for controlling the pressure/flow of breathing gas to a mechanical ventilator (4) by using an energy of breathing analysis and further to provide a pressure relief during exhalation and a trigger determination when to start the pressure relief using energy content of breathing in analysis for determining a pressure curve form during at least a portion of the expiration phase.