fix DB write