Refactored print_stats differently than instructed. I moved the whole block as it seemed more sensible.