refactor and extend argment processing