improved replace_ordinal