update middleware functions