fix kd tree bug