Fixed bug that was causing middleware not to work