fix invalid reads