moved process.wait inside too