Adds write order in toDB Function