Main method Middleware