Improve the middleware example with custom command