restore check ahead of the lock to avoid locking when not needed