fix bug for calculating cardinality ratio