fixed the count bug