fixing shared memory read/write