created some subfunctions for parsing the input and header