Fixing race condition with worker manipulation