fixed bug with header detection