Add two alternative implementation for count occurrences.