critical section implementation updated