race condition bugfix