Moved the following code into LaunchProcess and refactored the duplicate code in if/else