Functional seqstat, but slow, need to refactor out the while loop and dependencies on previous results