finished parser main function