added method for finding the closest node