oops -- fixed scoping of counter