middleware passing almost implemented