Recoded nearest neighbor for efficiency, code cleanliness, and to have it work correctly