updated with  middleware changes