add code bug fix write results