MOD: optimize critical section