a hopefully close to working parser