Compute and check distances