fixed meanDistance bug.