Added synchronize lock for critical section