fix length computation in dn_expand