A non-transitory computer readable medium embodied with programming code executable by a processor, and the processor when executing the programming code it causes the processor to: monitor a number of blood glucose measurements of a user; determine, at predetermined intervals, a value of a user's insulin onboard; in response to a determination that the user's insulin onboard is less than or equal to zero, determine a rate of change of the number of blood glucose measurements; as a result of the determination, modify a confidence value, wherein the confidence value is related to a duration of insulin action setting, wherein modifying the confidence value comprises: in response to a determination that the rate of change of the number of blood glucose measurements is a positive rate of change, decrease the confidence value; in response to a determination that the rate of change of the number of blood glucose measurements is a negative rate of change, increase the confidence value; modify, based on the modified confidence value, a duration of insulin action setting, wherein modifying the duration of insulin action setting comprises: comparing a confidence value to a positive threshold; in response to a determination the confidence value is greater than the positive threshold, increase the duration of insulin action setting; comparing the confidence value to a negative threshold; in response to a determination the confidence value is less than the negative threshold, decrease the duration of insulin action setting; determine timing of an insulin dose based on the modified duration of insulin action setting; and output a command signal to deliver an insulin dose based on the determined timing. monitor a number of blood glucose measurements of a user; determine, at predetermined intervals, a value of a user's insulin onboard; in response to a determination that the user's insulin onboard is less than or equal to zero, determine a rate of change of the number of blood glucose measurements; as a result of the determination, modify a confidence value, wherein the confidence value is related to a duration of insulin action setting, wherein modifying the confidence value comprises: in response to a determination that the rate of change of the number of blood glucose measurements is a positive rate of change, decrease the confidence value; in response to a determination that the rate of change of the number of blood glucose measurements is a negative rate of change, increase the confidence value; in response to a determination that the rate of change of the number of blood glucose measurements is a positive rate of change, decrease the confidence value; in response to a determination that the rate of change of the number of blood glucose measurements is a negative rate of change, increase the confidence value; modify, based on the modified confidence value, a duration of insulin action setting, wherein modifying the duration of insulin action setting comprises: comparing a confidence value to a positive threshold; in response to a determination the confidence value is greater than the positive threshold, increase the duration of insulin action setting; comparing the confidence value to a negative threshold; in response to a determination the confidence value is less than the negative threshold, decrease the duration of insulin action setting; comparing a confidence value to a positive threshold; in response to a determination the confidence value is greater than the positive threshold, increase the duration of insulin action setting; comparing the confidence value to a negative threshold; in response to a determination the confidence value is less than the negative threshold, decrease the duration of insulin action setting; determine timing of an insulin dose based on the modified duration of insulin action setting; and output a command signal to deliver an insulin dose based on the determined timing.