changed a little bit of kd tree structure