fix error message
refactor into cmds module, left app global res, atexit the cleanup