I have found the problem and resolved it, I was not reading my own script and missed out the IF statement.

Thanks