complete the nearest method