Re-ordered write function statements