Set up before inserting middleware