extracting distance from lookup table