further improvements on exception handling