refactored print_text()