middleware design