Believe this was what was wrong, when I added a global variable, it worked.