fixed a bug within parent distance calculation