fix issue with distance computation