adding middleware