Separated the parsing from the main loop