Before K-D tree implementation