half working refactor using techniques from riak_Dt