fix incorrect exception handling