refactoring readHeader methods