Finished parser, divided into functions