implementing find nearest