copied fix from stats.py to check