restruct to allow use as library. to run multiple cmds per session