wrote most of k-nearest I think