fix err in looping over headers