Well your AScan doesnt look right, it will return the index of a found element so the way you have it would only work if it found the OS in index 0. I would also get rid of all the GOTO nightmares. And I dont see the $os variable being set anywhere. Is this the full code? If not I'd recommend posting the entire script so we can provide more help.