improve histogram orientation check
add try/catch block to prevent parse completion