adding checks to fail on mismatch between reads and writes