Bug fix on uninitialized middleware array