fix header sent errors