update for nearest neighbor