added count by function