Improve nearest method.