inserts middleware into slots