middleware fix