fix race conditions in update