refactor parse_args function