Fix broken count implementation