more complex middleware