Wrap scope in if table exists check