better middleware integration