implemented range
implement nearest