header footer logic