Better handling of empty input

If empty distance = 0.