Correct the range detection in case of negative values