fix countByUser function queries