update to a middleware and add examples