Added try-catch blocks surrounding the subprocess method calls.