BUG: distance equals to tmp when threshold for order 0 is not passed
BUG: values for order 0 are now properly implemented
BUG: values for order 0 are now properly implemented
BUG: values for order 0 are now properly implemented