add better debug() for middleware