Clear some code to make it more obvious

I've looked for about an hour at that code and didn't quite understand why you had to iterate backwards over all the middleware, especially `prev` and `curr` threw me off.

For me this is a clearer approach, as it's more obvious that you iterate backwards to add the context to each function generator.