implementing automerge