refactor error handling.
refactor header type.
refactor