sequence is preserved when replacing middleware