refactor main to a function; add argparse;
update documentation