read and parse header