update counter;fix header already sent