working in middleware