added function to find nearest node