moved parser out of main function