Thanks for that, a great help
One question, when it has updated the gateway how do I get it to break the loop and continue, at present the script runs indefinately.

Thanks again