change countmin from uint32 to uint8 to save memory