refactor argument parsing