move extraction of stats to function so this can be done for first or second level