Implemented Nearest
bug fix nearest