write to DB fix data bug