Changed NearestInSpan to NearestWithinSpan and added panic for out of range