improve performance when writing qual file