Fixed incorrect declaration of countBy function