implementing count