added locking to the persistance layer