the script complained when i tried to declare them only when i needed them. but yes you are correct and i completely missed that. i changed the script on my machine and declared the variables inside their respective subroutine and its working fine. thanks for pointing that out :)