corrected bug with kd-tree