A method of controlling a dispenser for dosing a detergent in a washing machine, said washing machine comprising: (i) measuring means for measuring at least one parameter c* corresponding to the concentration of the detergent in a solution present in at least part of said washing machine, (ii) a dispenser to dispense said detergent, said dispenser being equipped with an reversibly closable output device having a minimum opening time tmin the dispenser has to be opened, (iii) a dispenser controller coupled to said measuring means and said dispenser, including at least one processor and at least one non-volatile memory for recording, calculating, controlling and/or storing process parameters, said method including steps of: (a) after an initial mixing and/or waiting time, measuring said parameter c* to determine the current concentration of the detergent in the machine c* cur, (b) calculating the difference Δc* between the setpoint c*set and the current concentration in the machine c* cur, (c) calculating and storing the current feed rate per minimum opening time dc*/tmin based on a moving average of the last n dispensing events, (d) if necessary, initiating dispensing of said detergent to said machine by opening said reversibly closable output device for a dosing time tdos resulting from the ratio of the difference between the set point and the current concentration Δc* to the current feed rate dc*/t min, wherein dispensing only is initiated if c*cur is • either more than x1 below the setpoint c*set or • in the range of from (100%-x1) c*set to below 100% c*set and the sum of the current concentration and the increase in concentration per minimum opening time (c*cur + dc*) does not exceed (100%+x2) c* set, wherein x1 is 0 < x1 ≤ 25% and x2 is 0 < x2≤ 40%. (i) measuring means for measuring at least one parameter c* corresponding to the concentration of the detergent in a solution present in at least part of said washing machine, (ii) a dispenser to dispense said detergent, said dispenser being equipped with an reversibly closable output device having a minimum opening time tmin the dispenser has to be opened, (iii) a dispenser controller coupled to said measuring means and said dispenser, including at least one processor and at least one non-volatile memory for recording, calculating, controlling and/or storing process parameters, (a) after an initial mixing and/or waiting time, measuring said parameter c* to determine the current concentration of the detergent in the machine c* cur, (b) calculating the difference Δc* between the setpoint c*set and the current concentration in the machine c* cur, (c) calculating and storing the current feed rate per minimum opening time dc*/tmin based on a moving average of the last n dispensing events, (d) if necessary, initiating dispensing of said detergent to said machine by opening said reversibly closable output device for a dosing time tdos resulting from the ratio of the difference between the set point and the current concentration Δc* to the current feed rate dc*/t min, • either more than x1 below the setpoint c*set or • in the range of from (100%-x1) c*set to below 100% c*set and the sum of the current concentration and the increase in concentration per minimum opening time (c*cur + dc*) does not exceed (100%+x2) c* set,