fixed small bug when handling exception