fixing an edge case bug with exception capture