fix write order