main loop added, parser revised