Fixed countAll procedure