fix log and write order