Moved header regex outside of function

This should improve performance