implemented and added test for counter()