Functions to construct a Kd-tree
fixing typos