added stat collecting to utils.py