cherry pick fix for ordering bug on insert