Implement document replace and update functionality.