modify write db code