finish fundamental of middleware