broken code- tried to localize global variables