changed logic for count method