tried to fix the count function