solve mongo db/sinatra/middleware issue