Implemented critical section macro