ported ocr to new functions