refine exception handling