Updated distances.py with normalization