cleaner code, refactor header management