fix the knn bug caused by smart pointer
first energy term checked