Seperated main into parsing functions