fixed write procedure