error on countVisits() wrong select