Implemented the parser in the main while loop