improved parsing of ocr output