implemented the count method