refactor shell invocation