Parsing properly until last IF statement