print_text() refactored