first working version of segscan