refactor print_line