added hash check before testing for error key