simulator: updated write function