consolidate exception handling