updated middleware