tally-repeat partially refactored. much more to do