fixed dictionary building in stats.py