counter: use local variables instead of instance variables