working parser with improvements