adding share_memory fn