anchor.diff:  				(belongs_to_snapshot(Threshold,(lists:last(Value))#clocksi_payload.snapshot_time)) end, OpsDict).
   
   
  -%% @doc Garbage collection triggered by writes.
  -%%	TODO: THIS FUNCTION WILL BE NEEDED WHEN WE USE OP BASED CRDTS. NOW IT IS IMPOSSIBLE
  -%%	THAT IT WILL BE CALLED AS EACH UPDATE GENERATES A SNAPSHOT AND, THEREFORE, SNAPSHOT_GC
  -%%  IS USED.
  -
  -%%snapshot_insert_gc(Key, SnapshotDict, OpsDict, SnapshotCache, OpsCache)-> 
  -%%	case (orddict:size(Ops))==?OPS_THRESHOLD of 
  -%%	true ->
  -%%		lager:info("pruning the following ops cache: ~p",[OpsDict]),
  -%%		PrunedOps=orddict:from_list(lists:sublist(orddict:to_list(OpsDict), 1+?OPS_THRESHOLD-?OPS_MIN, ?OPS_MIN)),
  -%%		lager:info("Result is: ~p",[PrunedOps]),
  -%%		FirstOp=lists:nth(1, PrunedOps),
  -%%		CommitTime= FirstOp#clocksi_payload.commit_time,
  -%%		lager:info("generating a snapshot that includes the operations to be removed from the cache, before commit time: ~p ~n ~p",[CommitTime,OpsDict]),
  -%%		{ok, {_SnapshotCommitTime, LatestSnapshot}}=get_latest_snapshot(SnapshotDict, SnapshotTime),
  -%%		TO BE CONTINUED FROM HERE.
  -%%		RemovedOps=prune_ops(OpsDict, CommitTime),
  -%%		%lager:info("Result is: ~p",[PrunedOps]),
  -%%		ets:insert(SnapshotCache, {Key, PrunedSnapshots}),
  -%%        ets:insert(OpsCache, {Key, PrunedOps}),
  -%%        true;
  -%%	false ->
  -%%		ets:insert(SnapshotCache, {Key, SnapshotDict}),
  -%%		%lager:info("NO NEED OF pruning the following snapshot cache: ~p",[SnapshotDict]),
  -%%		false
  -%%	end.
  -    
  -    
  -    
  +%% @doc Insert an operation and start garbage collection triggered by writes.
  +%% the mechanism is very simple; when there are more than OPS_THRESHOLD
  +%% operations for a given key, just perform a read, that will trigger
  +%% the GC mechanism.
  +
  +op_insert_gc(Key,DownstreamOp, OpsDict, OpsCache, SnapshotCache)-> 
  +    case (orddict:size(OpsDict))>=?OPS_THRESHOLD of 
  +    true ->
  +	    lager:info("too many operations: time to GC: ~p"),
  +	    Type=DownstreamOp#clocksi_payload.type,
  +	    SnapshotTime=DownstreamOp#clocksi_payload.snapshot_time,
  +	    lager:info("redading key: ~p ~n type: ~p ~n snapshot time: ~p", [Key, Type, SnapshotTime]),
  +	    Type=DownstreamOp#clocksi_payload.type,
  +	    SnapshotTime=DownstreamOp#clocksi_payload.snapshot_time,
  +	    internal_read(Key, Type, SnapshotTime, OpsCache, SnapshotCache);
  +	false ->
  +		continue
  +    end,
  +    lager:info("operation being stored: ~p", [DownstreamOp]),
  +    OpsDict1=orddict:append(DownstreamOp#clocksi_payload.commit_time, DownstreamOp, OpsDict),
  +    lager:info("materialiser_vnode: OpsDict= ~p",[OpsDict1]),
  +    true = ets:insert(OpsCache, {Key, OpsDict1}).
  +
  +     
  +    
  +    
  +    
  
positive.code: 
  handle_command({read, Key, Type, SnapshotTime}, _Sender,
  		State = #state{ops_cache=OpsCache, snapshot_cache=SnapshotCache}) ->
                            
      %lager:info("materialiser_vnode: operations: ~p", [Operations]),
      % get the latest snapshot for the key
      case ets:lookup(SnapshotCache, Key) of
      	[] ->
  
negative.code: 				end;
  			{ok, no_snapshot} ->
  				%%FIX THIS, READ FROM THE LOG WHEN THERE IS NO SNAPSHOT.
  				Snapshot=no_snapshot
  			end	
      end,
  	%lager:info("materialiser_vnode: snapshot: ~p", [Snapshot]),
  	Snapshot.
  	%TODO: trigger the GC mechanism asynchronously
  	%{async, snapshot_gc(), Sender, State};
  
  
  %% @doc Obtains, from an orddict of Snapshots, the latest snapshot that can be included in 
  