cleaned up middleware app-handler