implementation of middelware and next() logic