Refactor run shell commands style

Some refactoring on running shell commands