first version: mongo middleware