was using a global variable thinking it was local!