rewrite parse_arg and add some functions