refactor shell process logic