refactor new exception handling for better reuse