major refactor to parsing