middleware examples and related changes