Second version of Shared memory. Would be great to refactor