Update middleware code