updated to separate logic for header setting