A method for controlling a Modular Multilevel Converter, MMC,, connected to a first AC grid and to a second AC grid, the method comprising: calculating a first voltage reference (uR1ref) based on real power and reactive power of the second grid measured in real-time and on a predetermined reference for the real power (Pref) and for the reactive power (Qref); calculating a second voltage reference (uR2ref) comprising a current-dependent part and a voltage-dependent part, wherein: the current-dependent part is dependent on whether a real-time absolute value of grid current of the second grid is above a predefined current threshold (Imax), wherein the output (Lim(i)) of the current-dependent part is zero when the absolute value of the grid current is below the current threshold (Imax), whereby the output (Lim (i)) of the current-dependent part is based on the difference between the current threshold and the grid current when the absolute value of the grid current exceeds the current threshold, and the voltage-dependent part is dependent on whether an absolute value of a difference (ΔU) between grid voltage of the second grid measured in real-time and a synthetic grid voltage is above a predefined voltage threshold (ΔUmax), wherein the output (Lim(u)) of the voltage-dependent part is zero when the absolute value of the voltage difference (ΔU) is below the voltage threshold (ΔUmax), whereby the output (Lim (u)) of the voltage-dependent part is based on the difference between the voltage threshold and the grid voltage difference when the absolute value of the grid voltage difference exceeds the voltage threshold, and wherein the synthetic grid voltage is calculated based on a grid voltage amplitude (Û) of the second grid or an absolute value of the second grid voltage in the dq-frame (UR dq); and wherein the synthetic grid voltage is calculated being further based on an angular velocity (ω) of a Phase-Locked Loop, PLL; combining the first and second voltage references to a compounded reference voltage (uRref); and controlling output converter voltage (uR) of the MMC towards the second AC grid based on the compounded voltage reference. calculating a first voltage reference (uR1ref) based on real power and reactive power of the second grid measured in real-time and on a predetermined reference for the real power (Pref) and for the reactive power (Qref); calculating a second voltage reference (uR2ref) comprising a current-dependent part and a voltage-dependent part, wherein: the current-dependent part is dependent on whether a real-time absolute value of grid current of the second grid is above a predefined current threshold (Imax), wherein the output (Lim(i)) of the current-dependent part is zero when the absolute value of the grid current is below the current threshold (Imax), whereby the output (Lim (i)) of the current-dependent part is based on the difference between the current threshold and the grid current when the absolute value of the grid current exceeds the current threshold, and the voltage-dependent part is dependent on whether an absolute value of a difference (ΔU) between grid voltage of the second grid measured in real-time and a synthetic grid voltage is above a predefined voltage threshold (ΔUmax), wherein the output (Lim(u)) of the voltage-dependent part is zero when the absolute value of the voltage difference (ΔU) is below the voltage threshold (ΔUmax), whereby the output (Lim (u)) of the voltage-dependent part is based on the difference between the voltage threshold and the grid voltage difference when the absolute value of the grid voltage difference exceeds the voltage threshold, and wherein the synthetic grid voltage is calculated based on a grid voltage amplitude (Û) of the second grid or an absolute value of the second grid voltage in the dq-frame (UR dq); and wherein the synthetic grid voltage is calculated being further based on an angular velocity (ω) of a Phase-Locked Loop, PLL; the current-dependent part is dependent on whether a real-time absolute value of grid current of the second grid is above a predefined current threshold (Imax), wherein the output (Lim(i)) of the current-dependent part is zero when the absolute value of the grid current is below the current threshold (Imax), whereby the output (Lim (i)) of the current-dependent part is based on the difference between the current threshold and the grid current when the absolute value of the grid current exceeds the current threshold, and the voltage-dependent part is dependent on whether an absolute value of a difference (ΔU) between grid voltage of the second grid measured in real-time and a synthetic grid voltage is above a predefined voltage threshold (ΔUmax), wherein the output (Lim(u)) of the voltage-dependent part is zero when the absolute value of the voltage difference (ΔU) is below the voltage threshold (ΔUmax), whereby the output (Lim (u)) of the voltage-dependent part is based on the difference between the voltage threshold and the grid voltage difference when the absolute value of the grid voltage difference exceeds the voltage threshold, and wherein the synthetic grid voltage is calculated based on a grid voltage amplitude (Û) of the second grid or an absolute value of the second grid voltage in the dq-frame (UR dq); and wherein the synthetic grid voltage is calculated being further based on an angular velocity (ω) of a Phase-Locked Loop, PLL; combining the first and second voltage references to a compounded reference voltage (uRref); and controlling output converter voltage (uR) of the MMC towards the second AC grid based on the compounded voltage reference.