Added argparse and refactor print_output