trying to fix race conditions