changed knearest now in function
changed knearest now in function