added header footer handling