Bug fix: key error in finding headers