reorder invariant and adapt proof