Suffering from concurrency bug. I have no idea why