kNN add logic chunk