Hi afremont, thanks for the advice!
I will have a go at re-structuring the code now and let you know how I get on