fixed bug with subprocess wait method