some generalizations of stats scripts