fix write statements