Refactoring: simplifying Popen call