extract prepare logic for file-header