Replace os.system call with subprocess