Adding count_by method