add lock checking before safe putting/removing/writing