adjust header parsing algorithm