Rewrote parser to properly handle errors