fix exception processing logic