Start writing function for db update