refactor to tie header type to message