add argparse and do refactoring work