add count classes function