fix exception handling.