fixed bug in how nearest neighbors were being found