replace tunnel middleware with refactored version