with critical section