working version of GetSpan