fixing the encounter table scope issues