add write output function & structure.