finishing up refactor of stat generation code