Added argparse so this can be more easily controlled and tested