fix reading beyond actual size