Thanks wfsp for your very helpful posts. With your advice I was able to change the script. I updated the original code with the new one. The html for country and region warnings differ slightly. So I kept the original structure with different methods in subs.