Revise KNN to support dynamic K