fixed problem of simultaneous access to shared memory