rewrote using argparse instead of optparse