move some code to separate function
add tests for is-distance-short