Changed fr. sys.argv to argparse, separate main function