Updated the middleware to remove delay and be better