reordered middleware in app-handler
updated version