use upgrade lock (read write lock) instead of scoped lock