New version of db_write