memory usage optimizations for read and write operations

We can move the 2nd argument to the 1st line, so making the whole function call 3 lines.