moved header creation to function