A method for abating the presence of a selected chemical substance in wastewater flowing in a wastewater channel system from an upstream position to a downstream position, the method being carried out by a control unit, comprising - dosing into the wastewater, at the upstream position, chemical agent(s) adapted to abate the presence of said selected chemical substance, wherein the dosing is in an amount set by a dosing set-point, said dosing of chemical agent(s) being carried out by use of a dosing unit configured for dosing chemicals into the wastewater, the dosing unit being instructed by the control unit to dose chemicals in accordance with the dosing set-point, and - adjusting the dosing set-point based on determinations of the concentration of the selected chemical substance at the downstream position, - defining a threshold for the concentration of said selected chemical substance, said threshold being defined by a user; - determining a value of a pre-selected fractile based on a set of data comprising time series of concentration determinations of the selected chemical substance at the downstream position, said pre-selected fractile is set by a user and selected to have a value larger than the threshold, wherein adjusting the dosing set-point comprising: - obtaining a determination of concentration of the selected chemical substance, at the downstream position, said determination of concentration being obtained by use of a sensor configured for determining a concentration of said selected chemical substance and providing a sensor signal representing said concentration to the control unit and - i) if the determined concentration is lower than the value of the pre-selected fractile: adjusting the dosing set-point based on the difference between the determined concentration and the threshold, by decreasing the dosing set-point if the difference is smaller than zero and increasing the dosing set-point if the difference is larger than zero, wherein the decrease or increase is proportional to the difference; ii) if the determined concentration is higher than the value of the pre-selected fractile: adjusting the dosing set-point based on the difference between the value of the pre-selected fractile and the threshold, by increasing the dosing set-point proportional to the difference. - dosing into the wastewater, at the upstream position, chemical agent(s) adapted to abate the presence of said selected chemical substance, wherein the dosing is in an amount set by a dosing set-point, said dosing of chemical agent(s) being carried out by use of a dosing unit configured for dosing chemicals into the wastewater, the dosing unit being instructed by the control unit to dose chemicals in accordance with the dosing set-point, and - adjusting the dosing set-point based on determinations of the concentration of the selected chemical substance at the downstream position, - defining a threshold for the concentration of said selected chemical substance, said threshold being defined by a user; - determining a value of a pre-selected fractile based on a set of data comprising time series of concentration determinations of the selected chemical substance at the downstream position, said pre-selected fractile is set by a user and selected to have a value larger than the threshold, - obtaining a determination of concentration of the selected chemical substance, at the downstream position, said determination of concentration being obtained by use of a sensor configured for determining a concentration of said selected chemical substance and providing a sensor signal representing said concentration to the control unit and - i) if the determined concentration is lower than the value of the pre-selected fractile: adjusting the dosing set-point based on the difference between the determined concentration and the threshold, by decreasing the dosing set-point if the difference is smaller than zero and increasing the dosing set-point if the difference is larger than zero, wherein the decrease or increase is proportional to the difference; ii) if the determined concentration is higher than the value of the pre-selected fractile: adjusting the dosing set-point based on the difference between the value of the pre-selected fractile and the threshold, by increasing the dosing set-point proportional to the difference. i) if the determined concentration is lower than the value of the pre-selected fractile: adjusting the dosing set-point based on the difference between the determined concentration and the threshold, by decreasing the dosing set-point if the difference is smaller than zero and increasing the dosing set-point if the difference is larger than zero, wherein the decrease or increase is proportional to the difference; ii) if the determined concentration is higher than the value of the pre-selected fractile: adjusting the dosing set-point based on the difference between the value of the pre-selected fractile and the threshold, by increasing the dosing set-point proportional to the difference.