return Nil instead of -1 for distances outside range (not optimized)