rewrote OCR.java to a more FP style