better describe how middleware works