rewrite of run_model for k-NN