Fixed #3 Corrected mean distance calculation