category detect and count