updated error handling of ocr functions and merge hocr and ocr functions