Globals are not good, declare len