First working shared memory version