fix error with distance calculation between features