using global lock to protect