fixed race condition from reading
fix bug where instanceId is not checked for