debug middleware