Update internal logic of middleware scan