implemented upto longest-seq.