change some calls of tryTakeMVar to takeMVar to prevent potential race conditions