Adding Daniel's KNN code