bug fix in writer for if statement condition