added in-place reading