Made it work correctly with caught exceptions