added write lock for synchronization