refactor of print_summary