distance calculation fixed