The logic of the comment "the region between the high boundary and the maximum value must be treated as the optimum region" is correct. However, the code below covered only two cases, the optimum case was missing. Fixes #473
#define
else
if