minor refactoring for cmdline