wrote a find nearest function...