lesson4: building the middleware stack