set up middleware