A controller (10; 15; 80), comprising: a threshold detection circuit (13; 50) configured to receive a feedback signal (fb) indicative of a load current (I LED), and to detect when the load current (I LED) as indicated by the feedback signal (fb) reaches an upper current threshold or a lower current threshold, a control circuit (112; 84) configured to control a supply stage (11; 16, 17, 18) in response to the detecting, in order to supply a load with the load current (I LED), and a current error determination and compensation circuit configured to determine an on-time (t on) between a first point in time, where the load current (I LED) reaches the lower threshold current from above, and a second point in time, where the load current (I LED) reaches the upper current threshold from below, and an off-time (t off) between the second point in time and a following first point in time, and to adjust the upper current threshold and the lower current threshold based on the on-time (t on) and the off-time (t off), a storage, characterized in that the current error determination and compensation circuit is configured to determine a deviation of the load current from a nominal average load current based on the on-time, the off-time and a factor depending on an input voltage (V in), an inductance of an inductor of the supply stage and a control loop delay ( τ lοορ), wherein either the current determination and compensation circuit is configured to know the input voltage (V in), the inductance and the control loop delay ( τ loop) by design, by application scenario or measurement, and the storage comprises a look-up table comprising factor values, or the factor is programmed in the storage, wherein the current error determination and compensation circuit is configured to modify the upper current threshold and/or the lower current threshold adding or subtracting values, which values are based on the deviation of the load current from the nominal average load current, to or from the upper current threshold and/or the lower current threshold. a threshold detection circuit (13; 50) configured to receive a feedback signal (fb) indicative of a load current (I LED), and to detect when the load current (I LED) as indicated by the feedback signal (fb) reaches an upper current threshold or a lower current threshold, a control circuit (112; 84) configured to control a supply stage (11; 16, 17, 18) in response to the detecting, in order to supply a load with the load current (I LED), and a current error determination and compensation circuit configured to determine an on-time (t on) between a first point in time, where the load current (I LED) reaches the lower threshold current from above, and a second point in time, where the load current (I LED) reaches the upper current threshold from below, and an off-time (t off) between the second point in time and a following first point in time, and to adjust the upper current threshold and the lower current threshold based on the on-time (t on) and the off-time (t off), a storage, characterized in that the current error determination and compensation circuit is configured to determine a deviation of the load current from a nominal average load current based on the on-time, the off-time and a factor depending on an input voltage (V in), an inductance of an inductor of the supply stage and a control loop delay ( τ lοορ), wherein either the current determination and compensation circuit is configured to know the input voltage (V in), the inductance and the control loop delay ( τ loop) by design, by application scenario or measurement, and the storage comprises a look-up table comprising factor values, or the factor is programmed in the storage, wherein the current error determination and compensation circuit is configured to modify the upper current threshold and/or the lower current threshold adding or subtracting values, which values are based on the deviation of the load current from the nominal average load current, to or from the upper current threshold and/or the lower current threshold.