Changed logic problem with replacement of headers