Added middleware support