refactored out `print_stats`