optimistic lock implementation